home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / WANDR330.ZIP / SRC / GAME.C < prev    next >
Encoding:
C/C++ Source or Header  |  1997-01-05  |  20.5 KB  |  788 lines

  1. #include "wand_head.h"
  2. #include <curses.h>
  3.  
  4. extern int move_monsters();
  5. extern int jumpscreen();
  6. extern int check();
  7. extern void showpass();
  8. extern void draw_symbol();
  9. extern void display();
  10. extern int fall();
  11. extern void map();
  12. extern void redraw_screen();
  13. extern struct mon_rec *make_monster();
  14.  
  15. extern long dictsize;
  16. extern int debug_disp;
  17. extern int edit_mode;
  18. extern int record_file;
  19. extern char screen[NOOFROWS][ROWLEN+1];
  20. extern char *edit_memory;
  21. extern char *memory_end;
  22. extern WINDOW *win,*displaywin,*mapwin,*infowin;
  23. extern WINDOW *messagewin;
  24. extern int pause2;
  25. extern int pause1;
  26. extern int recording;
  27.  
  28. struct mon_rec start_of_list = {0,0,0,0,0,NULL,NULL};
  29. struct mon_rec *last_of_list, *tail_of_list;
  30.  
  31. /* Actual game function - Calls fall() to move boulders and arrows
  32.     recursively.
  33.    Variable explaination :
  34.     All the var names make sense to ME, but some people think them a bit confusing... :-) So heres an explanation.
  35.    x,y : where you are
  36.    nx,ny : where you're trying to move to
  37.    sx,sy : where the screen window on the playing area is
  38.    mx,my : where the monster is
  39.    tx,ty : teleport arrival
  40.    bx,by : baby monster position
  41.    nbx,nby : where it wants to be
  42.    lx,ly : the place you left when teleporting
  43.    nf : how many diamonds you've got so far
  44.    new_disp : the vector the baby monster is trying
  45. */
  46. extern int old_score; /* save old score in case of retry or killed */
  47.  
  48. char *playscreen(num, score, bell, maxmoves, keys)
  49. int  *num, maxmoves, *bell;
  50. long *score;
  51. char keys[10];
  52. {
  53.     int  x, y, nx, ny, deadyet = 0, sx = -1, sy = -1, tx = -1, ty = -1,
  54.      lx = 0, ly = 0, mx = -1, my = -1, newnum, 
  55.      diamonds = 0, nf = 0, tmpx, tmpy;
  56.     char (*frow)[ROWLEN+1] = screen,  buffer[25];
  57.     int ch;
  58.     struct mon_rec *monster;
  59.     static char howdead[25];    /* M001 can't use auto var for return value */
  60.     char *memory_ptr;
  61.  
  62.     old_score = *score;
  63.     tail_of_list = &start_of_list;
  64.     memory_ptr = edit_memory;
  65.  
  66.     for (x = 0; x <= ROWLEN; x++)
  67.     for (y = 0; y < NOOFROWS; y++) {
  68.         if ((screen[y][x] == '*') || (screen[y][x] == '+'))
  69.         diamonds++;
  70.             if (screen[y][x] == 'A') {    /* note teleport arrival point & */
  71.                     /* replace with space */
  72.         tx = x;
  73.         ty = y;
  74.         screen[y][x] = ' ';
  75.         }
  76.         if (screen[y][x] == '@') {
  77.         sx = x;
  78.         sy = y;
  79.         }
  80.         if (screen[y][x] == 'M') {    /* Put megamonster in */
  81.         mx = x;
  82.         my = y;
  83.         }
  84.         if (screen[y][x] == 'S') {    /* link small monster to pointer chain */
  85.         if ((monster = make_monster(x,y)) == NULL) {
  86.             strcpy(howdead,"running out of memory");
  87.             return howdead;
  88.         }
  89.         if (!viable(x,y-1)) {    /* make sure its running in the */
  90.                     /* correct direction.. */
  91.             monster->mx = 1;
  92.             monster->my = 0;
  93.         } else if (!viable(x+1,y)) {
  94.             monster->mx = 0;
  95.             monster->my = 1;
  96.         } else if (!viable(x,y+1)) {
  97.             monster->mx = -1;
  98.             monster->my = 0;
  99.         } else if (!viable(x-1,y)) {
  100.             monster->mx = 0;
  101.             monster->my = -1;
  102.         }
  103.         }
  104.         if (screen[y][x] == '-')
  105.         screen[y][x] = ' ';
  106.     }
  107.     x = sx;
  108.     y = sy;
  109.     if ((x == -1) && (y == -1)) {    /* no start position in screen ? */
  110.     strcpy(howdead,"a screen design error");
  111.     return(howdead);
  112.     }
  113.  
  114.     if (maxmoves < 1) maxmoves = -1;
  115.  
  116.     update_game:    /* M002  restored game restarts here */
  117.  
  118.     redraw_screen(bell,maxmoves,*num,*score,nf,diamonds,mx,sx,sy,frow);
  119.  
  120. /* ACTUAL GAME FUNCTION - Returns method of death in string */
  121.  
  122.     while (deadyet == 0) {
  123.     switch (recording) {
  124.     case 1:
  125.         ch = wgetch(win);
  126.         if((ch == keys[0]) || (ch == keys[1]) || (ch == keys[2]) ||
  127.                (ch == keys[3]) || (ch == ')') || (ch == '+')) 
  128.                 {
  129.             *memory_ptr++ = ch;
  130.             memory_end++;
  131.         if ((ch != ')') && (ch != '+')) maxmoves--;
  132.             break;
  133.         }
  134.  
  135.             else if  ((ch == KEY_LEFT) || (ch == KEY_RIGHT) ||
  136.                       (ch == KEY_DOWN) || (ch == KEY_UP) ||
  137.                       (ch == '-'))
  138.                 { /* only one byte to store path direction */
  139.                 maxmoves--;
  140.         if (ch == KEY_LEFT) ch = keys[2];
  141.         else if (ch == KEY_RIGHT) ch = keys[3];
  142.         else if (ch == KEY_UP) ch= keys[0];
  143.         else if (ch == KEY_DOWN) ch = keys[1];
  144.  
  145.             *memory_ptr++ = ch;
  146.             memory_end++;
  147.             break;
  148.         }
  149.  
  150.         else break;
  151.  
  152.     case 2:
  153.         ch = *memory_ptr++;
  154.         if (wgetch(win) != ERR)  /* check for interrupt */
  155.               ch=')';
  156.         delay(pause2); /* slow it down */
  157.         maxmoves--;
  158.         if (ch == '\0')
  159.         ch = ')';
  160.         break;
  161.     default:
  162.         ch =  wgetch(win);
  163.         if((ch == keys[0]) || (ch == keys[1]) || (ch == keys[2]) ||
  164.                (ch == keys[3])) maxmoves--;
  165.             else if  ((ch == KEY_LEFT) || (ch == KEY_RIGHT) ||
  166.                       (ch == KEY_DOWN) || (ch == KEY_UP)) maxmoves--; 
  167.  
  168.     }
  169.  
  170.     if ((record_file != -1) && (ch != 'q')) write(record_file,&ch,1);
  171.  
  172.     nx = x;
  173.     ny = y;
  174.  
  175. #ifdef MSDOS
  176.     if ((ch == KEY_RIGHT) && (x <(ROWLEN-1)))  /* move about - but thats obvious */
  177.         nx++;
  178.     if ((ch == KEY_LEFT) && (x > 0))
  179.         nx--;
  180.     if ((ch == KEY_DOWN) && (y <(NOOFROWS-1)))
  181.         ny++;
  182.     if ((ch == KEY_UP) && (y > 0))
  183.         ny--;
  184. #endif
  185.     if ((ch == keys[3]) && (x <(ROWLEN-1)))  /* move about - but thats obvious */
  186.         nx++;
  187.     if ((ch == keys[2]) && (x > 0))
  188.         nx--;
  189.     if ((ch == keys[1]) && (y <(NOOFROWS-1)))
  190.         ny++;
  191.     if ((ch == keys[0]) && (y > 0))
  192.         ny--;
  193.  
  194.  
  195.  
  196.     if (ch == '1') {    /* Add or get rid of that awful sound */
  197.         *bell = 1;
  198.         wmove(infowin,5,0);
  199.         waddstr(infowin,"Bell on ");
  200.         wrefresh(infowin);
  201.         continue; /* don't move monsters */
  202.     }
  203.     if (ch == '0') {
  204.         *bell = 0;
  205.         wmove(infowin,5,0);
  206.         waddstr(infowin,"Bell off");
  207.         wrefresh(infowin);
  208.         continue;
  209.     }
  210.     if (ch == '~') {    /* level jump */
  211.         if (edit_mode)
  212.         continue;
  213.         if ((newnum = jumpscreen(*num)) == 0) {
  214.         strcpy(howdead,"a jump error.");
  215.         return howdead;
  216.         }
  217.         if (newnum != *num) {    /* Sorry Greg, no points for free */
  218.         sprintf(howdead,"~%c",newnum);
  219.         return howdead;
  220.         }
  221.         continue;
  222.     }
  223.     if (ch == 'r') {       /* restart same level */
  224.        if(recording==1)
  225.         {
  226.         wmove(messagewin,0,0);
  227.         waddstr(messagewin,"Stop recording first\n");
  228.         wrefresh(messagewin);
  229.         }
  230.       else
  231.         {
  232.         wclear(messagewin);
  233.         wrefresh(messagewin);
  234.         *score = old_score;
  235.         sprintf(howdead,"~%c",*num);
  236.         return howdead;
  237.         }
  238.         }
  239.     if (ch == '!') {    /* look at the map */
  240.         if (debug_disp)
  241.         continue;
  242.             win=mapwin;
  243.         map(frow);
  244.         werase(win); /* clear everything or else we are left with */
  245.         wrefresh(win); /* remnants of map */
  246.             win=displaywin;
  247.         wclear(win); /* have to clear it or else wrefresh thinks its
  248.                unchanged */
  249.          redraw_screen(bell,maxmoves,*num,*score,nf,diamonds,mx,sx,sy,frow);
  250.         continue;
  251.     }
  252.     if (ch == 'q') {
  253.         strcpy(howdead,"quitting the game");
  254.         return howdead;
  255.     }
  256.     if (ch == '?') {
  257.         wbkgd(mapwin,COLOR_PAIR(1));
  258.         wbkgd(displaywin,COLOR_PAIR(1));
  259.         helpme(1);
  260.         wbkgd(mapwin,COLOR_PAIR(2));
  261.         wbkgd(displaywin,COLOR_PAIR(2));
  262.         if (debug_disp)
  263.                 {
  264.                 win=mapwin;
  265.         map(frow);
  266.                 }
  267.         else
  268.                 {
  269.                 win=displaywin;
  270.         display(sx,sy,frow);
  271.                 }
  272.         continue;
  273.     }
  274.     if ((ch == '@') && (!debug_disp)) {
  275.         sx = x;
  276.         sy = y;
  277.         display(sx,sy,frow);
  278.         continue;
  279.     }
  280.     if (ch == '#') {
  281.         debug_disp = 1 - debug_disp;
  282.         if (debug_disp)
  283.                 {
  284.                 win=mapwin;
  285.         map(frow);
  286.                 }
  287.         else {
  288.         wclear(win);
  289. /*
  290.         for (tmpy = 0;tmpy <= (NOOFROWS+1); tmpy++) {
  291.             wmove(win,tmpy,0);
  292.             for (tmpx = 0;tmpx <= (ROWLEN+2); tmpx++)
  293.             waddch(win,' ');
  294.                }*/
  295.         erase();
  296.         refresh();
  297.         win=displaywin;
  298.  
  299.         wclear(win);
  300.         sx = x; sy = y;
  301.          redraw_screen(bell,maxmoves,*num,*score,nf,diamonds,mx,sx,sy,frow);
  302.         /* display(sx,sy,frow);*/
  303.         }
  304.         continue;
  305.     }
  306.     if ((ch == 'W') || ((int)ch == 12)) {
  307.         redraw_screen(bell,maxmoves,*num,*score,nf,diamonds,mx,sx,sy,frow);
  308.         continue;
  309.     }
  310.  
  311. /* Edit screen memory functions */
  312.     /* if (edit_memory) */ {
  313.         if ((ch == '(') && (recording == 0)) {    /* start recording from beginning */
  314.         memory_end = memory_ptr = edit_memory;
  315.         wmove(infowin,10,0);
  316.         waddstr(infowin," -Recording-");
  317.         wrefresh(infowin);
  318.         recording = 1;
  319.         continue;
  320.         }
  321.         if ((ch == ')') && ( recording != 0)) {    /* stop recording or playback */
  322.         recording = 0;
  323.         nodelay(win,FALSE);
  324.         wmove(infowin,10,0);
  325.         waddstr(infowin," -- End --  ");
  326.         wrefresh(infowin);
  327.         wmove(infowin,10,0);
  328.         waddstr(infowin," -Occupied- ");
  329.         continue;
  330.         }
  331.         if ((ch == '*') && (recording == 0)) {    /* playback memory */
  332.         memory_ptr = edit_memory;
  333.         recording = 2;
  334.         wmove(infowin,10,0);
  335.         waddstr(infowin," -Playback- ");
  336.         wrefresh(infowin);
  337.         nodelay(win,TRUE);
  338.         continue;
  339.         }
  340.         if ((ch == '&') && (recording == 0)) {    /* extend recording, either  */
  341.                             /* from end or from checkpoint */
  342.         recording = 1;
  343.         wmove(infowin,10,0);
  344.         waddstr(infowin," -Recording-");
  345.         wrefresh(infowin);
  346.         if (*(memory_ptr -1) != '-')
  347.             memory_ptr--;
  348.         continue;
  349.         }
  350.  
  351.         if ((ch == '+') && (recording == 0) && (memory_ptr < memory_end)) {
  352.         /* continue from checkpoint */
  353.         recording = 2;
  354.         wmove(infowin,10,0);
  355.         waddstr(infowin," -Playback- ");
  356.         wrefresh(infowin);
  357.         continue;
  358.         }
  359.  
  360.         if ((ch == '-') && (recording != 0)) {    /* create or react to a checkpoint */
  361.         /* checkpoint */
  362.         wmove(infowin,10,0);
  363.         waddstr(infowin,"-Checkpoint-");
  364.         wrefresh(infowin);
  365.         wmove(infowin,10,0);
  366.         if (recording == 2) {
  367.             recording = 0;
  368.             waddstr(infowin," -Occupied- ");
  369.         } else waddstr(infowin," -Recording-");
  370.             continue;
  371.         }
  372.  
  373.         if ((ch == '>') && (pause2 >0))
  374.         {
  375.         pause2--;
  376.         if(pause2>25) pause2 -= 4;
  377.         wmove(infowin,12,0);
  378.         sprintf(buffer,"Play pause = %d  ",pause2);
  379.         waddstr(infowin,buffer);
  380.         wrefresh(infowin);
  381.         continue;
  382.         }
  383.  
  384.         if ((ch == '<') && (pause2 < 100))
  385.         {
  386.         pause2++;
  387.         if(pause2>25) pause2 +=4;
  388.         wmove(infowin,12,0);
  389.         sprintf(buffer,"Play pause = %d  ",pause2);
  390.         waddstr(infowin,buffer);
  391.         wrefresh(infowin);
  392.         continue;
  393.         }
  394.     }
  395. /* end of memory functions */
  396.  
  397.     if ((ch == 'm') && (pause1 < 100))
  398.        {
  399.        pause1++;
  400.        if(pause1 >25) pause1 +=4;
  401.        wmove(infowin,14,0);
  402.        sprintf(buffer,"Animation delay = %d  ",pause1);
  403.        waddstr(infowin,buffer);
  404.        wrefresh(infowin);
  405.        continue;
  406.        }
  407.  
  408.     if ((ch == 'n') && (pause1 > 0))
  409.        {
  410.        pause1--;
  411.        if(pause1>25) pause1 -= 4;
  412.        wmove(infowin,14,0);
  413.        sprintf(buffer,"Animation delay = %d  ",pause1);
  414.        waddstr(infowin,buffer);
  415.        wrefresh(infowin);
  416.        continue;
  417.        }
  418.  
  419.  
  420. /* M002  Added save/restore game feature.  Gregory H. Margo */
  421.     if (ch == 'S') {    /* save game */
  422.         extern struct save_vars zz;
  423.  
  424.         /* stuff away important local variables to be saved */
  425.         /* so the game state may be acurately restored    */
  426.         zz.z_x        = x;
  427.         zz.z_y        = y;
  428.         zz.z_sx        = sx;
  429.         zz.z_sy        = sy;
  430.         zz.z_tx        = tx;
  431.         zz.z_ty        = ty;
  432.         zz.z_mx        = mx;
  433.         zz.z_my        = my;
  434.         zz.z_diamonds    = diamonds;
  435.         zz.z_nf        = nf;
  436.  
  437.         save_game(*num, score, bell, maxmoves);
  438.         /* NOTREACHED ... unless there's been an error. */
  439.     }
  440.     if (ch == 'R') {    /* restore game */
  441.         extern struct save_vars zz;
  442.  
  443.         restore_game(num, score, bell, &maxmoves);
  444.  
  445.         /* recover important local variables */
  446.         x        = zz.z_x;
  447.         y        = zz.z_y;
  448.         sx        = zz.z_sx;
  449.         sy        = zz.z_sy;
  450.         tx        = zz.z_tx;
  451.         ty        = zz.z_ty;
  452.         mx        = zz.z_mx;
  453.         my        = zz.z_my;
  454.         diamonds    = zz.z_diamonds;
  455.         nf        = zz.z_nf;
  456.  
  457.         goto update_game;    /* the dreaded goto    */
  458.     }
  459.  
  460.     if (ch == 18)     /* ctrl r -- read memory data */
  461.         edit_restore();
  462.     if (ch == 23)     /* ctrl w -- write memory data */
  463.         edit_save();
  464.  
  465.     if (screen[ny][nx] == 'C') {
  466.         screen[ny][nx] = ':';
  467.         *score+=4;
  468.         if (maxmoves != -1)
  469.         maxmoves+=250;
  470.     }
  471.  
  472.  
  473.  
  474.     switch (screen[ny][nx]) {
  475.     case '@': break;
  476.     case '*': *score+=9;
  477.         nf++;
  478.         sprintf(buffer,"diamonds = %d/%d  ",nf,diamonds); 
  479.             wmove(infowin,3,0);
  480.             waddstr(infowin,buffer);
  481.         wrefresh(infowin);
  482. #ifdef NOISY
  483.         if (*bell) printf("\007");
  484. #endif
  485.     case ':': *score+=1;
  486.         sprintf(buffer,"score = %d  ",*score);
  487.             wmove(infowin,2,0);
  488.         waddstr(infowin,buffer);
  489.         wrefresh(infowin);
  490.     case ' ':
  491.         screen[y][x] = ' ';
  492.         screen[ny][nx] = '@';
  493.         if (!debug_disp) {
  494.         draw_symbol((x-sx+5)*3,(y-sy+3)*2,' ');
  495.         draw_symbol((nx-sx+5)*3,(ny-sy+3)*2,'@');
  496.         } else {
  497.         draw_object(y+1,x+1,' ');
  498.                 draw_object(ny+1,nx+1,'@');
  499.         }
  500.         deadyet += check(&mx,&my,x,y,nx-x,ny-y,sx,sy,howdead);
  501.         wrefresh(win);
  502.         y = ny;
  503.         x = nx;
  504.         break;
  505.     case 'O':
  506.         if ((nx == 0) || (nx == ROWLEN)) break;
  507.         if (screen[y][nx*2-x] == 'M') {
  508.         screen[y][nx*2-x] = ' ';
  509.         mx = my = -1;
  510.         *score+=100;
  511.               sprintf(buffer,"score = %d  ",*score);
  512.                 wmove(infowin,2,0);
  513.             waddstr(infowin,buffer);
  514.         wrefresh(infowin);
  515.         draw_symbol(50,11,' ');
  516.         move(16,0);
  517.         wrefresh(win);
  518.         }
  519.         if (screen[y][nx*2-x] == ' ') {
  520.         screen[y][nx*2-x] = 'O';
  521.         screen[y][x] = ' ';
  522.         screen[ny][nx] = '@';
  523.         if (!debug_disp) {
  524.             draw_symbol((x-sx+5)*3,(y-sy+3)*2,' ');
  525.             draw_symbol((nx-sx+5)*3,(ny-sy+3)*2,'@');
  526.             if (nx*2-x>sx-6&&nx*2-x<sx+6)
  527.             draw_symbol((nx*2-x-sx+5)*3,(y-sy+3)*2,'O');
  528.         } else {
  529.             draw_object(y+1,x+1,' ');
  530.                     draw_object(ny+1,nx+1,'@');
  531.                     draw_object(y+1,nx*2-x+1,'O');
  532.         }
  533.         deadyet += fall(&mx,&my,nx*2-x,y+1,sx,sy,howdead);
  534.         deadyet += fall(&mx,&my,x*2-nx,y,sx,sy,howdead);
  535.         deadyet += fall(&mx,&my,x,y,sx,sy,howdead);
  536.         deadyet += fall(&mx,&my,x,y-1,sx,sy,howdead);
  537.         deadyet += fall(&mx,&my,x,y+1,sx,sy,howdead);
  538.         move(16,0);
  539.         wrefresh(win);
  540.         y = ny;
  541.         x = nx;
  542.         }
  543.         break;
  544.     case '^':
  545.         if ((nx == 0) || (nx == ROWLEN)) break;
  546.         if (screen[y][nx*2-x] == ' ') {
  547.         screen[y][nx*2-x] = '^';
  548.         screen[y][x] = ' ';
  549.         screen[ny][nx] = '@';
  550.         if (!debug_disp) {
  551.             draw_symbol((x-sx+5)*3,(y-sy+3)*2,' ');
  552.             draw_symbol((nx-sx+5)*3,(ny-sy+3)*2,'@');
  553.             if (nx*2-x > sx-6 && nx*2-x < sx+6)
  554.                 draw_symbol((nx*2-x-sx+5)*3,(y-sy+3)*2,'^');
  555.         } else {
  556.             draw_object(y+1,x+1,' ');
  557.             draw_object(ny+1,nx+1,'@');
  558.                     draw_object(y+1,nx*2-x+1,'^');
  559.         }
  560.         deadyet += fall(&mx,&my,nx*2-x,y-1,sx,sy,howdead);
  561.         deadyet += fall(&mx,&my,x*2-nx,y,sx,sy,howdead);
  562.         deadyet += fall(&mx,&my,x,y,sx,sy,howdead);
  563.         deadyet += fall(&mx,&my,x,y+1,sx,sy,howdead);
  564.         deadyet += fall(&mx,&my,x,y-1,sx,sy,howdead);
  565.         move(16,0);
  566.         wrefresh(win);
  567.         y = ny;
  568.         x = nx;
  569.         }
  570.         break;
  571.     case '<':
  572.     case '>':
  573.         if ((ny == 0) || (ny == NOOFROWS)) break;
  574.         if (screen[ny*2-y][x] == 'M') {
  575.         screen[ny*2-y][x] = ' ';
  576.         mx = my = -1;
  577.         *score+=100;
  578.               sprintf(buffer,"score = %d  ",*score);
  579.                 wmove(infowin,2,0);
  580.             waddstr(infowin,buffer);
  581.             wrefresh(infowin);
  582.         draw_symbol(50,11,' ');
  583.         move(16,0);
  584.         wrefresh(win);
  585.         }
  586.         if (screen[ny*2-y][x] == ' ') {
  587.         screen[ny*2-y][x] = screen[ny][nx];
  588.         screen[y][x] = ' ';
  589.         screen[ny][nx] = '@';
  590.         if (!debug_disp) {
  591.             draw_symbol((x-sx+5)*3,(y-sy+3)*2,' ');
  592.             draw_symbol((nx-sx+5)*3,(ny-sy+3)*2,'@');
  593.             if (ny*2-y > sy-4 && ny*2-y < sy+4)
  594.             draw_symbol((x-sx+5)*3,(ny*2-y-sy+3)*2,screen[ny*2-y][x]);
  595.         } else {
  596.             draw_object(y+1,x+1,' ');
  597.             draw_object(ny+1,nx+1,'@');
  598.             draw_object(ny*2-y+1,x+1,screen[ny*2-y][x]);
  599.         }
  600.         deadyet += fall(&mx,&my,x,y,sx,sy,howdead);
  601.         deadyet += fall(&mx,&my,x-1,(ny>y)?y:(y-1),sx,sy,howdead);
  602.         deadyet += fall(&mx,&my,x+1,(ny>y)?y:(y-1),sx,sy,howdead);
  603.         deadyet += fall(&mx,&my,x-1,ny*2-y,sx,sy,howdead);
  604.         deadyet += fall(&mx,&my,x+1,ny*2-y,sx,sy,howdead);
  605.         move(16,0);
  606.         wrefresh(win);
  607.         y = ny;
  608.         x = nx;
  609.         }
  610.         break;
  611.     case '~':
  612.         if (((2*nx-x) < 0) || ((ny*2-y) > NOOFROWS) || ((ny*2-y) < 0) ||
  613.         ((2*nx-x) > ROWLEN)) break;
  614.         if (screen[ny*2-y][nx*2 -x] == 'M') {
  615.         screen[ny*2-y][nx*2-x] = ' ';
  616.         mx = my = -1;
  617.         *score+=100;
  618.               sprintf(buffer,"score = %d  ",*score);
  619.                 wmove(infowin,2,0);
  620.             waddstr(infowin,buffer);
  621.         wrefresh(infowin);
  622.         draw_symbol(50,11,' ');
  623.         move(16,0);
  624.         wrefresh(win);
  625.         }
  626.         if (screen[ny*2-y][nx*2-x] == ' ') {
  627.         screen[ny*2-y][nx*2-x] = '~';
  628.         screen[y][x] = ' ';
  629.         screen[ny][nx] = '@';
  630.         if (!debug_disp) {
  631.             draw_symbol((x-sx+5)*3,(y-sy+3)*2,' ');
  632.             draw_symbol((nx-sx+5)*3,(ny-sy+3)*2,'@');
  633.             if ((ny*2-y > sy-4) && (ny*2-y < sy+4))
  634.             draw_symbol((nx*2-x-sx+5)*3,(ny*2-y-sy+3)*2,'~');
  635.         } else {
  636.             draw_object(y+1,x+1,' ');
  637.             draw_object(ny+1,nx+1,'@');
  638.             draw_object(ny*2-y+1,nx*2-x+1,'~');
  639.         }
  640.         deadyet += check(&mx,&my,x,y,nx-x,ny-y,sx,sy,howdead);
  641.         move(16,0); wrefresh(win);
  642.         y = ny; x = nx;
  643.         }
  644.         break;
  645.     case '!':
  646.         strcpy(howdead,"an exploding landmine");
  647.         deadyet = 1;
  648.         if (!debug_disp) {
  649.         draw_symbol((x-sx+5)*3,(y-sy+3)*2,' ');
  650.         draw_symbol((nx-sx+5)*3,(ny-sy+3)*2,'%');
  651.         } else {
  652.         draw_object(y+1,x+1,' ');
  653.         draw_object(ny+1,nx+1,'@');
  654.         }
  655.         wrefresh(win);
  656.         break;
  657.     case 'X':
  658.         if (nf == diamonds) {
  659.         *score+=250;
  660.         if (dictsize)    /* if passwords are enabled */
  661.             showpass(*num);
  662.         return NULL;
  663.         }
  664.         break;
  665.     case 'T':
  666.         if (tx > -1) {
  667.         screen[ny][nx] = ' ';
  668.         screen[y][x] = ' ';
  669.         lx = x;
  670.         ly = y;
  671.         y = ty;
  672.         x = tx;
  673.         screen[y][x] = '@';
  674.         sx = x;
  675.         sy = y;
  676.         *score += 20;
  677.               sprintf(buffer,"score = %d  ",*score);
  678.                 wmove(infowin,2,0);
  679.             waddstr(infowin,buffer);
  680.         wrefresh(infowin);
  681.         if (!debug_disp)
  682.             display(sx,sy,frow);
  683.         else
  684.             map(frow);
  685.         deadyet += fall(&mx,&my,nx,ny,sx,sy,howdead);
  686.         if (deadyet == 0)
  687.             deadyet = fall(&mx,&my,lx,ly,sx,sy,howdead);
  688.         if (deadyet == 0)
  689.             deadyet = fall(&mx,&my,lx+1,ly-1,sx,sy,howdead);
  690.         if (deadyet == 0)
  691.             deadyet = fall(&mx,&my,lx+1,ly+1,sx,sy,howdead);
  692.         if (deadyet == 0)
  693.             deadyet = fall(&mx,&my,lx-1,ly+1,sx,sy,howdead);
  694.         if (deadyet == 0)
  695.             deadyet = fall(&mx,&my,lx-1,ly-1,sx,sy,howdead);
  696.         move(16,0);
  697.         wrefresh(win);
  698.         } else {
  699.         screen[ny][nx] = ' ';
  700.         printf("Teleport out of order");
  701.         }
  702.         break;
  703.     case 'M':
  704.         strcpy(howdead,"a hungry monster");
  705.         deadyet = 1;
  706.         if (!debug_disp)
  707.         draw_symbol((x-sx+5)*3,(y-sy+3)*2,' ');
  708.         else 
  709.         draw_object(y+1,x+1,' ');
  710.         wrefresh(win);
  711.         break;
  712.     case 'S':
  713.         strcpy(howdead,"walking into a monster");
  714.          deadyet = 1;
  715.         if (!debug_disp)
  716.         draw_symbol((x-sx+5)*3,(y-sy+3)*2,' ');
  717.         else {
  718.         draw_object(y+1,x+1,' ');
  719.         }
  720.         wrefresh(win);
  721.         break;
  722.     default:
  723.         break;
  724.     }
  725.     if ((y == ny) && (x == nx) && (maxmoves > 0)) {
  726.         sprintf(buffer,"max moves = %d ",maxmoves);
  727.         wmove(infowin,4,0);
  728.         waddstr(infowin,buffer);
  729.             wrefresh(infowin);
  730.     }
  731.     if (maxmoves == 0) {
  732.         strcpy(howdead,"running out of time");
  733.         deadyet = 1;
  734.         if (edit_mode) maxmoves = -1;
  735.     }
  736.     if (!debug_disp) {
  737.         if ((x < (sx-3)) && (deadyet == 0)) {    /* screen scrolling if necessary */
  738.         sx-=6;
  739.         if (sx < 4)
  740.             sx = 4;
  741.         display(sx,sy,frow);
  742.         }
  743.         if ((y < (sy-2)) && (deadyet == 0)) {
  744.         sy-=5;
  745.         if (sy < 2)
  746.             sy = 2;
  747.         display(sx,sy,frow);
  748.             }
  749.         if ((x > (sx+3)) && (!deadyet)) {
  750.         sx+=6;
  751.         if (sx > (ROWLEN -5))
  752.             sx = ROWLEN -5;
  753.         display(sx,sy,frow);
  754.         }
  755.         if ((y > (sy+2)) && (!deadyet)) {
  756.         sy+=5;
  757.         if (sy > (NOOFROWS-3))
  758.             sy = NOOFROWS -3;
  759.         display(sx,sy,frow);
  760.         }
  761.     }
  762.  
  763.     deadyet += move_monsters(&mx,&my,score,howdead,sx,sy,nf,*bell,x,y,diamonds);
  764.  
  765.     if ((edit_mode) && (deadyet)) {    /* stop death if testing */
  766.         recording = 0;
  767.         wmove(infowin,10,0);
  768.         waddstr(infowin,"-Occupied- ");
  769.         wmove(messagewin,2,0);
  770.         waddstr(messagewin,"You were killed by ");
  771.         waddstr(messagewin,howdead);
  772.         waddstr(messagewin,"\nPress 'c' to continue.");
  773.         wrefresh(messagewin);
  774.         ch = wgetch(win);
  775.         if (ch == 'c')
  776.         deadyet = 0;
  777.           wmove(messagewin,20,2);
  778.         waddstr(messagewin,"                                                              ");
  779.         waddstr(messagewin,"\n                      ");
  780.         wrefresh(messagewin);
  781.     }
  782.  
  783.     }
  784.     if(recording==1)
  785.     *(memory_ptr-2) = ')'; /* step back to avoid death */
  786.     return(howdead);
  787. }
  788.